#ifndef __GAME_CONFIG_H__
#define __GAME_CONFIG_H__
#include "cocos2d.h"
#include "../tinyxml/tinyxml.h"
#include <string>
namespace fishingjoy
{
	namespace config
	{
		class CGameConfig
		{
			static std::string m_strBeginSceneBg;
			static std::string m_strPlaySceneBg;
			static int m_ExtendSize;
			static int m_MaxFishNum;
			static std::string m_strBgMusic;
			static void load()
			{
				if(m_strBeginSceneBg==""){
					TiXmlDocument doc;
					std::string pathKey = "config/game.xml"; 
					pathKey = cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(pathKey.c_str());	
					if(doc.LoadFile(pathKey.c_str())){
						TiXmlElement* root = doc.RootElement();
						TiXmlElement* node = root->FirstChildElement();
						while(node){
							std::string str = node->Value();
							if(str=="begin"){
								m_strBeginSceneBg = node->GetText();
							}
							else if(str=="play"){
								m_strPlaySceneBg = node->GetText();
							}
							else if(str == "extend"){
								m_ExtendSize = atoi(node->GetText());
							}
							else if(str =="max_fish"){
								m_MaxFishNum = atoi(node->GetText());
							}
							else if(str =="bg_music"){
								m_strBgMusic = node->GetText();
							}
							node = node->NextSiblingElement();
						}
					}
				}
			}
		public:
			static const char* getBeginSceneBg()
			{
				load();
				return m_strBeginSceneBg.c_str();
			}
			static const char* getPlaySceneBg()
			{
				load();
				return m_strPlaySceneBg.c_str();
			}
			static int getExtendSize()
			{
				return m_ExtendSize;
			}
			static int getMaxFishNum()
			{
				return m_MaxFishNum;
			}

			static const char* getBgMusic()
			{
				load();
				return m_strBgMusic.c_str();
			}
		};
	}

}
#endif